package com.excilys.formation.projet.ebanking.modele;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

@Entity
@Table(name = "UTILISATEUR")
public class Utilisateur {
	
	public enum eRole {
		ROLE_ADMIN, ROLE_CLIENT
	};
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "UTL_ID")
	private int id;
	@Column(name = "UTL_NOM")
	private String nom;
	@Column(name = "UTL_PRENOM")
	private String prenom;
	@Column(name = "UTL_LOGIN", unique = true)
	private String login;
	@Column(name = "UTL_PASSWORD")
	private String password;
	@Column(name = "UTL_ADR_RUE")
	private String adresseRue;
	@Column(name = "UTL_ADR_COMPL")
	private String adresseCompl;
	@Column(name = "UTL_ADR_CP")
	private String adresseCp;
	@Column(name = "UTL_ADR_VILLE")
	private String adresseVille;
	@Column(name = "UTL_TEL")
	private String tel;
	@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinTable(name = "REL_UTILISATEUR_ROLE", joinColumns = @JoinColumn(name = "UTL_ID"), inverseJoinColumns = @JoinColumn(name = "ROL_ID"))
	private List<Role> roles;
	@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinTable(name = "REL_UTILISATEUR_COMPTE", joinColumns = @JoinColumn(name = "UTL_ID"), inverseJoinColumns = @JoinColumn(name = "CPT_ID"))
	private List<Compte> comptes;
	
	public int getId() {
		return id;
	}
	
	public void setId(int id) {
		this.id = id;
	}
	
	public String getNom() {
		return nom;
	}
	
	public void setNom(String nom) {
		this.nom = nom;
	}
	
	public String getPrenom() {
		return prenom;
	}
	
	public void setPrenom(String prenom) {
		this.prenom = prenom;
	}
	
	public String getLogin() {
		return login;
	}
	
	public void setLogin(String login) {
		this.login = login;
	}
	
	public String getPassword() {
		return password;
	}
	
	public void setPassword(String password) {
		this.password = password;
	}
	
	public String getAdresseRue() {
		return adresseRue;
	}
	
	public void setAdresseRue(String adr_rue) {
		this.adresseRue = adr_rue;
	}
	
	public String getAdresseCompl() {
		return adresseCompl;
	}
	
	public void setAdresseCompl(String adr_compl) {
		this.adresseCompl = adr_compl;
	}
	
	public String getAdresseCp() {
		return adresseCp;
	}
	
	public void setAdresseCp(String adr_cp) {
		this.adresseCp = adr_cp;
	}
	
	public String getAdresseVille() {
		return adresseVille;
	}
	
	public void setAdresseVille(String adr_ville) {
		this.adresseVille = adr_ville;
	}
	
	public String getTel() {
		return tel;
	}
	
	public void setTel(String tel) {
		this.tel = tel;
	}
	
	public List<Role> getRoles() {
		return roles;
	}
	
	public void setRoles(List<Role> lstRoles) {
		this.roles = lstRoles;
	}
	
	public void setComptes(List<Compte> comptes) {
		this.comptes = comptes;
	}
	
	public List<Compte> getComptes() {
		return comptes;
	}
	
}
